import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CakeCompositionVO, CakeCompositionForm, CakeCompositionQuery } from '@/api/sj/cakeComposition/types';

/**
 * 查询蛋糕选配列表
 * @param query
 * @returns {*}
 */

export const listCakeComposition = (query?: CakeCompositionQuery): AxiosPromise<CakeCompositionVO[]> => {
  return request({
    url: '/sj/cakeComposition/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询蛋糕选配详细
 * @param id
 */
export const getCakeComposition = (id: string | number): AxiosPromise<CakeCompositionVO> => {
  return request({
    url: '/sj/cakeComposition/' + id,
    method: 'get'
  });
};

/**
 * 新增蛋糕选配
 * @param data
 */
export const addCakeComposition = (data: CakeCompositionForm) => {
  return request({
    url: '/sj/cakeComposition',
    method: 'post',
    data: data
  });
};

/**
 * 修改蛋糕选配
 * @param data
 */
export const updateCakeComposition = (data: CakeCompositionForm) => {
  return request({
    url: '/sj/cakeComposition',
    method: 'put',
    data: data
  });
};

/**
 * 删除蛋糕选配
 * @param id
 */
export const delCakeComposition = (id: string | number | Array<string | number>) => {
  return request({
    url: '/sj/cakeComposition/' + id,
    method: 'delete'
  });
};
